package orm.infrastructure.converters;

import orm.er.PersonMock;
import orm.er.AddressMock;
import orm.er.PhoneMock;
import orm.infrastructure.interfaces.IMockConverter;

/**
 * Created with IntelliJ IDEA.
 * User: Awake
 * Date: 03.05.12
 * Time: 17:40
 * To change this template use File | Settings | File Templates.
 */

public class ConverterFactory {

    public static IMockConverter GetInstance(Class type) {

        IMockConverter instance = null;

        if (type == null)
            throw new IllegalStateException("Argument is null");

        if (type.equals(PersonMock.class))
            instance =  new APersonConverter();

        if (type.equals(PhoneMock.class))
            instance =  new PhoneConverter();

        if (type.equals(AddressMock.class))
            instance =  new AddressConverter();

        if (instance == null)
            throw new IllegalStateException("Unsupported instance");

        return instance;

    }

}
